-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add gyro bmi160 and fix gyro i2c address #83
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @AutoPlantBali Thanks for your contribution. I'd like to ask, that did you build any craft with this gyro? can you confirm that this code works "in the air"? Can you show any blacbox recording?
Fix for alternative i2c address looks fine.
Cheers
lib/Espfc/src/Device/GyroBMI160.h
Outdated
|
||
/* Issue a dummy-read to force the device into SPI comms mode */ | ||
uint8_t dummy = 0; | ||
_bus->readByte(_addr, 0x7F, &dummy); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avoid using magic numbers in code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will add it to the define list
lib/Espfc/src/Device/GyroBMI160.h
Outdated
delay(1); | ||
|
||
// Set Accel ODR to 400hz, BWP mode to Oversample 4, LPF of ~40.5hz | ||
_bus->writeByte(_addr, BMI160_RA_ACCEL_CONF, 0x0A); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this comment match real setting? 400 Hz ODR and 40Hz LPF is actually useless, either for accel and gyro.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** Get accelerometer output data rate.
- The acc_odr parameter allows setting the output data rate of the accelerometer
- as described in the table below.
- 5 = 25/2Hz
- 6 = 25Hz
- 7 = 50Hz
- 8 = 100Hz
- 9 = 200Hz
- 10 = 400Hz
- 11 = 800Hz
- 12 = 1600Hz
- 13 = 3200Hz
lib/Espfc/src/Device/GyroBMI160.h
Outdated
|
||
int getRate() const override | ||
{ | ||
return 8000; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't studied the BMI160 documentation deeply yet, but it seems that its native operating frequency is 3200Hz. It is good for ODR to be equal to gyro reading rate. So return 3200 here, and set correct ODR in setRate()
method below. You can find proper formula in datasheet. Accel ODR is not as much important, can be fixed on frequency close to 500Hz.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will fix it by taking the response from the sensor
I made a board that supports mpu6500, mpu9250, bmi160, lsm6ds and bmp280. Next month I will order the PCB and start assembling it. I will show the results of testing using this sensor |
Hi @AutoPlantBali, I merged your changes to develop branch, as I want to do some tests first. Next time It would be better if you put different features and fixes in separate PRs. Thanks again. |
Hi @AutoPlantBali I've connected brand new BMI160 gyro, and calibration not passed. It seems that gyro has stored inaccurate offset values in NVM, this caused that gyro bias for x and y axis was around 10 deg/s. If I turn off applying offset, then bias is about 1 deg/s. Can you test these changes from develop branch with your device? |
esp32 bmi160 on spi
esp32 bmi160 on i2c
rp2040 bmi160 on spi
fix i2c address detect 0x76 and 0x77
#81